package bulidStream;

import java.util.function.IntSupplier;
import java.util.stream.IntStream;

/**
 * @Author wangtengyu
 * @Create 2018-06-06-16:57
 */
public class FeboDemo2 {
    public static void main(String[] args) {

        IntSupplier intSupplier=new IntSupplier() {
            private int previous=0;
            private int current=1;

            @Override
            public int getAsInt() {
                int oldPrevious=this.previous;
                int nextValue=this.previous+this.current;
                this.previous=this.current;
                this.current=nextValue;
                return oldPrevious;
            }
        };

        IntStream intStream=IntStream.generate(intSupplier);
        intStream.limit(10).forEach(System.out::println);
    }
}
